package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Reference
    private UserService userService;

    @RequestMapping("/login")
    public boolean login(@RequestBody User user) {
        boolean flag = false;
        User u = userService.findByUsernameAndPassword(user.getUsername(), user.getPassword());
        if (u != null) {
            flag = true;
        }
        return flag;
    }
}
